package com.xd.study.activity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.xd.study.R;

/**
 * Created by DGF on 2015/4/22.
 */
public class CheckBoxActivity extends Activity {

    private CheckBox checkBox;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.checkbox);

        checkBox = (CheckBox)this.findViewById(R.id.checkBox);
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                CharSequence txt = checkBox.getText();
                if (isChecked) {
                    Log.i("tag", txt + "被选中");
                } else {
                    Log.i("tag", txt + "未选中");
                }
            }
        });
    }
}
